package cn.moefly.algorithm.sort;

import java.util.function.BiFunction;

public interface SortAlgoRithm {
    int ASC = 0;
    int DESC = 1;

    BiFunction<Integer,Integer,Boolean> GT = (a,b)-> a > b;
    BiFunction<Integer,Integer,Boolean> LT = (a,b)-> a < b;
    BiFunction<Integer,Integer,Boolean> GE = (a,b)-> a >= b;
    BiFunction<Integer,Integer,Boolean> LE = (a,b)-> a <= b;

    int[] sort(int[] source,int type);

    default void switchNum(int[] arr, int pos1, int pos2){
        //如果不做相等位置判断的话，就会因为没有使用辅助变量的运算而出现0的情况
        if (pos1 == pos2){return;}
        arr[pos1] = arr[pos1] ^ arr[pos2];
        arr[pos2] = arr[pos1] ^ arr[pos2];
        arr[pos1] = arr[pos1] ^ arr[pos2];
    }


}
